﻿package com.view.my_view;

import com.badibadi.mytools.DisplayUtil;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class ABC_ListView extends ListView {
	public String[] ABC = { "A", "B", "C", "D", "E", "F", "G", "H", " I", "J",
			"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
			"X", "Y", "Z" };
	Context ct;

	public ABC_ListView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
		init(context);
	}

	public ABC_ListView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		init(context);
	}

	public ABC_ListView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		init(context);
	}

	private void init(Context context) {
		ct = context;
		ABC_ListViewAdapter adapter2 = new ABC_ListViewAdapter();
		this.setAdapter(adapter2);
	}

	@Override
	public void addView(View child) {
		// TODO Auto-generated method stub
		super.addView(child);
	}

	@Override
	public void setAdapter(ListAdapter adapter2) {
		// TODO Auto-generated method stub
		super.setAdapter(adapter2);
	}

	// @Override
	// public void setDividerHeight(int height) {
	// // TODO Auto-generated method stub
	// super.setDividerHeight(1);
	// }
	//
	// //隐藏活动条
	// @Override
	// public void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
	// {
	// // TODO Auto-generated method stub
	// super.setVerticalScrollBarEnabled(true);
	// }

	class ABC_ListViewAdapter extends BaseAdapter {

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return ABC.length;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return ABC[position];
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			TextView tv = new TextView(ct);
			tv.setText(ABC[position]);
			tv.setTextSize(DisplayUtil.dip2px(ct, 8));
			return tv;
		}

	}
}
